package com.unytech.project.service.system.impl;

import java.util.List;
import java.util.Set;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.unytech.project.entity.system.Permission;
import com.unytech.project.entity.system.User;
import com.unytech.project.service.base.BaseDao;
import com.unytech.project.service.system.PermissionService;

@Service 
@Transactional
public class PermissionServiceImpl extends BaseDao<Permission> implements PermissionService {
	
	public Set<Permission> getPermissionEntity(List permissionids)
	{
		Set<Permission> permissionset = null;
		Permission permtemp = null;
		for (int i=0; i<permissionset.size(); i++)
		{
			permtemp = em.find(Permission.class, permissionids.get(i));
			if (permtemp != null)
			{
				permissionset.add(permtemp);
			}
		}
		return permissionset;
	}

	/**此方法暂时没用，注意删除接口中的方法*/
	public List<Permission> getPermissions(User user)
	{		
		List<Permission> permlist = null;
		if (user.getUsername().equals(systemParams.getAdminname()) && user.getPassword().equals(systemParams.getAdminpwd())) {
			try {
				permlist = findAll();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		
		
		return permlist;
		
	}
}
